import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_services/model/server_sugar_detail_data.dart';
import 'package:basic_services/serviceDetail/service_detail_controller.dart';
import 'package:basic_widgets/text_widget.dart';
class SugarInfoView extends GetView<ServerDetailController> {
  ServerSugarDetailData detailData;
  SugarInfoView({required this.detailData});
  @override
  Widget build(BuildContext context) {
    List<SriList> list = detailData.sriList!;
    SriList? srLiiData;
    if (list.isNotEmpty) {
      srLiiData = list[0];
    }
    return Container(
      width: ScreenHelper.screenWidth,
      alignment: Alignment.center,
      padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
      margin: EdgeInsets.symmetric(
          horizontal: ScreenHelper.width(15),
          vertical: ScreenHelper.height(10)),
      color: Colors.white,
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.symmetric(vertical: 6),
            child: textItemWidget(
                attrName: '检查时间',
                value: '${checkStatus(srLiiData!.mealsFlag!)}',
                fontSize: 16,
                valuColor: AppTheme.dartTextColor),
          ),
          Container(
            margin: EdgeInsets.symmetric(vertical: 6),
            child: textItemWidget(
                attrName: '血糖值',
                value: '${srLiiData.value} mmol/L',
                fontSize: 16,
                valuColor: AppTheme.dartTextColor),
          ),
          Container(
            margin: EdgeInsets.symmetric(vertical: 6),
            child: textItemWidget(
                attrName: '评估',
                value: '${srLiiData.evaluate}',
                fontSize: 16,
                valuColor: AppTheme.dartTextColor),
          )
        ],
      ),
    );
  }

  String checkStatus(String status) {
    String str = "";
    switch (status) {
      case "1":
        str = "餐前";
        break;
      case "2":
        str = "餐后";
        break;
      case "3":
        str = "睡前";
        break;
      case "4":
        str = "凌晨";
        break;
    }
    return str;
  }
}
